--[[
* 目标身上每有一个减益状态，我方对其攻击时将增加5%暴击率
 * 这个buff是挂在敌人身上, 实际是buff 减少自己的暴击韧性
]]
---@class BuffEffect300036000:BaseBuffEffect
BuffEffect300036000 = ClientFight.CreateClass("BuffEffect300036000", ClientFight.BaseBuffEffect)
local BuffEffect300036000 = "BuffEffect300036000";
local t = BuffEffect300036000


---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local oldValue = buff.effectParams[BuffEffect300036000] or 0;
    buff.effectParams[BuffEffect300036000] = 1+oldValue;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s buff%s 目标身上每有一个减益状态,减少暴击韧性, 减益buff数量: %s",
            fight.frame, buff.target.fighterId, buff.modelId,oldValue+1));
    local newValue = oldValue+1;
    buff.attributes.attributes[FighterAttributeEnum.CRIT_RES.id] = -1*buff.buffBean.f_BuffEffectValue[1]*newValue;

    ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

---@param fight Fight
---@param buff FighterBuff
---@param force number
function t:remove(fight, buff,force,...)
    local parameters = {...};
    if (buff.targe:isDie()) then
        ClientFight.BaseBuffEffect.remove(self,fight, buff, force, parameters);
    end
    local oldValue = buff.effectParams[BuffEffect300036000] or 0;
    local newValue = oldValue - 1;
    if (newValue < 0) then
    newValue = 0;
    end
    buff.effectParams[BuffEffect300036000] = newValue;
    buff.attributes.attributes[FighterAttributeEnum.CRIT_RES.id] = -1*buff.buffBean.f_BuffEffectValue[1]*newValue;
    local logValue = newValue;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s buff%s 目标身上每有一个减益状态,减少暴击韧性, 减益buff数量: %s",
    fight.frame, buff.target.fighterId, buff.modelId,logValue));

    FighterAttributeManager.countFighterAttribute(fight,buff.target, CalculatorTypeEnum.BUFF);
    return IBuffEffect.FAIL;
end

t.New()